package com.xiaoshuidi.cloud.module.iot.dal.access.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xiaoshuidi.cloud.module.iot.dal.access.DeviceOperationDataAccess;
import com.xiaoshuidi.cloud.module.iot.dal.access.mapper.DeviceOperationMapper;
import com.xiaoshuidi.cloud.module.iot.dal.pojo.TbDeviceOperation;
import com.xiaoshuidi.cloud.module.iot.dal.repository.DeviceOperationRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * <br>
 *
 * @author Porter
 * create by 2019/7/5
 * @Emial Porter.Wang@ixiaoshuidi.com
 */
@Service
public class DeviceOperationDataAccessImpl implements DeviceOperationDataAccess {

    @Autowired
    private DeviceOperationRepository deviceOperationRepository;
    @Override
    public int insterDeviceOperationRecord(TbDeviceOperation tbDeviceOperation) {
        deviceOperationRepository.save(tbDeviceOperation);
        return tbDeviceOperation.getId();
    }

    @Override
    public Boolean updateDeviceOperationRecord(TbDeviceOperation tbDeviceOperation) {
        return deviceOperationRepository.updateById(tbDeviceOperation);
    }

    @Override
    public Boolean deleteOperateRecord(String deviceNo) {
        return deviceOperationRepository.remove(Wrappers.<TbDeviceOperation>query().lambda().eq(TbDeviceOperation::getDeviceNo, deviceNo));
    }
}
